import request from "../request";
import qs from 'qs'

// 商品分类
//分页获取 商品分类
export const queryProductCategoryListApi = (params: IProductCategoryListParams): RSP<IUserListData<IProductCategoryModel>> => request.get(`/productCategory/list/${params.parentId}`, { params });
// 添加商品分类
export const createProductCategoryApi = (params: IAddProductCategory): RSP<any> => request.post('/productCategory/create', params)
// 获取所有商品属性分类及其下属性
export const getProductCategoryAttrApi = (): RSP<IProductCategoryAttrModel[]> => request.get('/productAttribute/category/list/withAttr',)
// 获取id商品分类
export const getIDCategoryApi = (id: number): RSP<IAddProductCategory> => request.get(`/productCategory/${id}`)
// 编辑商品分类
export const editIDCategoryApi = (params: IEditProCateParams): RSP<IProductCategoryModel> => request.post(`/productCategory/update/${params.id}`, params.productCategoryParam)
// 删除商品分类
export const delIDCategoryApi = (id: number): RSP<any> => request.post(`
/productCategory/delete/${id}`)
// 修改导航栏显示状态
export const uptProCateNavStatusApi = (params: IUpdateNavStatusParams): RSP<any> => request.post('/productCategory/update/navStatus', qs.stringify(params, { arrayFormat: "comma" }))
// 修改显示状态
export const uptProCatShowStatusApi = (params: IUpdateShowStatusParams): RSP<any> => request.post('/productCategory/update/showStatus', qs.stringify(params, { arrayFormat: "comma" }))


// 品牌
export const getProBrandsApi = (params: IUserListParams): RSP<IUserListData<IProBrandsModel>> => request.get('/brand/list', { params })
// 新增品牌
export const createProBrandApi = (params: IProBrandsParams): RSP<any> => request.post('/brand/create', params)
// 编辑商品品牌
export const updateProBrandApi = (params: IEditParams<IProBrandsParams>): RSP<any> => request.post(`/brand/update/${params.id}`, params.editParams)
// 根据id查询品牌
export const getIDProBrandApi = (id: number): RSP<IProBrandsModel> => request.get(`/brand/${id}`)

// 修改导航栏显示状态
export const updateFactoryStatusApi = (params: IUpdatefactoryStatusParams): RSP<any> => request.post('/brand/update/factoryStatus', qs.stringify(params, { arrayFormat: "comma" }))
// 修改显示状态
export const uptBrandShowStatusApi = (params: IUpdateShowStatusParams): RSP<any> => request.post('/brand/update/showStatus', qs.stringify(params, { arrayFormat: "comma" }))


// 属性分类管理
// 分页请求属性 /productAttribute/category/list
export const getProAttrsApi = (params: IUserListParams): RSP<IUserListData<IattributeListModel>> => request.get('/productAttribute/category/list', { params })
// 添加属性分类/productAttribute/category/create
export const CreateProductAttributeCategoryApi = (params: { name: string }): RSP<any> => request.post('/productAttribute/category/create', qs.stringify(params, { arrayFormat: "comma" }))
// 获取单个商品属性分类信息/productAttribute/category/{id}
export const getIDProductAttributeApi = (id: number): RSP<IattributeListModel> => request.get(`/productAttribute/category/${id}`)
// 修改属性/productAttribute/category/update/{id}
export const updateProductAttributeCategoryApi = (params: { id: number, name: string }): RSP<any> => request.post(`/productAttribute/category/update/${params.id}`, qs.stringify(params, { arrayFormat: 'comma' }))

// 属性管理
// 根据分类查询属性列表或参数列表 /productAttribute/list/{cid}
export const getProductAttributeListApi = (params: IProductAttributeParams): RSP<IUserListData<IProductAttributeModel>> => request.get(`/productAttribute/list/${params.cid}?pageNum=${params.pageNum}&pageSize=${params.pageSize}&type=${params.type}`)

// 添加商品属性信息 /productAttribute/create
export const createProductAttributeApi = (params: ICreateProductAttributeParams): RSP<any> => request.post('/productAttribute/create', params)

// /productAttribute/{id}查询单个商品属性
export const getIDproductAttributeApi = (id: number): RSP<IProductAttributeModel> => request.get(`/productAttribute/${id}`)

// /productAttribute/update/{id}修改商品属性信息
export const updateIDProductAttributeApi = (params: IEditParams<ICreateProductAttributeParams>): RSP<any> => request.post(`/productAttribute/update/${params.id}`, params.editParams)

// /productAttribute/delete 批量删除商品属性
export const deleteProductAttributeApi = (params: { ids: number[] }): RSP<any> => request.post('/productAttribute/delete', qs.stringify(params, { arrayFormat: 'comma' }))

// /productAttribute/category/delete/{id} 删除单个商品属性分类
export const deleteProductAttributeCategoryApi = (id: number): RSP<IProductAttributeModel> => request.get(`/productAttribute/category/delete/${id}`)



// 商品列表
// 分页请求 商品 /product/list
export const getProductListApi = (params?: IGetProductListParams): RSP<IUserListData<IProductListModel>> => request.get('/product/list', { params })

// /productCategory/list/withChildren 查询所有一级分类及子分类
export const getProductCategoryWithChildrenApi = (): RSP<IProductCategoryWithChildrenModel[]> => request.get('/productCategory/list/withChildren')
// /product/update/newStatus 批量设为新品
export const updateProductNewStatusApi = (params: { ids: number[], newStatus: number }): RSP<any> => request.post('/product/update/newStatus', qs.stringify(params, { arrayFormat: 'comma' }))
// /product/update/publishStatus批量上下架
export const updateProductPublishStatusApi = (params: { ids: number[], publishStatus: number }): RSP<any> => request.post('/product/update/publishStatus', qs.stringify(params, { arrayFormat: 'comma' }))
// /product/update/recommendStatus批量推荐商品
export const updateProductRecommendStatusApi = (params: { ids: number[], recommendStatus: number }): RSP<any> => request.post('/product/update/recommendStatus', qs.stringify(params, { arrayFormat: 'comma' }))
// /product/update/verifyStatus批量修改审核状态
export const updateProductVerifyStatusApi = (params: { ids: number[], verifyStatus: number, detail: string }): RSP<any> => request.post('/product/update/verifyStatus', qs.stringify(params, { arrayFormat: 'comma' }))
// /product/update/deleteStatus批量修改删除状态
export const updateProductDeleteStatusApi = (params: { ids: number[], deleteStatus: number }): RSP<any> => request.post('/product/update/deleteStatus', qs.stringify(params, { arrayFormat: 'comma' }))

// /sku/{pid} 根据商品编号及sku编码模糊搜索sku库存  params.keyword
export const queryIDSKUApi = (params: ISKUParams): RSP<ISKUListModel> => request.get(`/sku/${params.pid}`)
// /product/create 创建商品
export const createProductApi = (params: ICreateProductParams): RSP<any> => request.post('/product/create', params)
// /memberLevel/list 查询所有会员等级
export const queryMemberLevelListApi = (defaultStatus: number): RSP<IMemberListModel[]> => request.get(`/memberLevel/list?defaultStatus=${defaultStatus}`)
// /prefrenceArea/listAll 获取所有商品优选
export const queryPrefrenceAreaListApi = (): RSP<IPrefrenceAreaList[]> => request.get('/prefrenceArea/listAll')
// /subject/listAll 获取全部商品专题
export const querySubjectListAllApi = (): RSP<ISubjectListAll[]> => request.get('/subject/listAll')

// /product/updateInfo/{id} 根据商品id获取商品编辑信息
export const getIDPproductproductUpdateInfoApi = (id: number): RSP<ICreateProductParams> => request.get(`/product/updateInfo/${id}`)

// /product/update/{id} 更新商品
export const updateIDPproductproductUpdateInfoApi = (id: number, productParamL: ICreateProductParams): RSP<any> => request.post(`/product/update/${id}`, productParamL)